<%-- 
    Document   : Home
    Created on : Apr 21, 2013, 10:59:58 PM
    Author     : Sean
--%>

<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@page import="java.util.ArrayList, business.*, databaseproject.*;" contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Review</title>
        <link rel="stylesheet" type="text/css" href="site.css">
    </head>
    <body>
        
 <%

String name = (String) request.getAttribute("Name");
String phone = (String) request.getAttribute("Phone");
String email = (String) request.getAttribute("Email");
String shippingAddress = (String) request.getAttribute("ShippingAddress");
String shippingCity = (String) request.getAttribute("ShippingCity");
String billingAddress = (String) request.getAttribute("BillingAddress");
String shippingState = (String) request.getAttribute("ShippingState");
String shippingZip = (String) request.getAttribute("ShippingZip");
String cardName = (String) request.getAttribute("Cardholdername");
String cardNumber = (String) request.getAttribute("Cardnumber");
String expMonth = (String) request.getAttribute("expmonth");
String expYear = (String) request.getAttribute("expyear");
String billingCity = (String) request.getAttribute("BillingCity");
String billingState = (String) request.getAttribute("BillingState");
String billingZip = (String) request.getAttribute("BillingZip");

%>
        
        
        <div id="Main-wrapper">
            
            <div id="header-wrapper">
                <div id="header">
                    <div class="header-content">
                        IST 411 E-Commerce
                    </div> 
                </div>

                
            </div>
            
            <div id="Main-content">
                <div class="steps">
                    <div style="float: left; width: 320px; border: 1px solid black; text-align: center; padding-top: 4px; padding-bottom: 4px; font-weight: bold;">
                        1. &nbsp; &nbsp;  Shipping
                    </div>
                    <div style="float: left; width: 320px; border: 1px solid black; text-align: center; padding-top: 4px; padding-bottom: 4px; font-weight: bold;">
                        2. &nbsp; &nbsp;  Billing
                    </div>
                    <div style="float: left; width: 320px; border: 1px solid black; text-align: center; padding-top: 4px; padding-bottom: 4px; font-weight: bold; background: #ccccff;">
                        3. &nbsp; &nbsp;  Review
                    </div>
                    <div style="clear: both;"></div>
                </div>
                
                <h1>Review Your Order</h1>
                
                <hr/>
                <div>
                    <form action="confirmation.jsp">
                        <div style="min-height: 400px; border: 1px solid #8d8d8d;">
                            <div style="float: left; width: 300px; padding: 8px;">
                                <span style="text-decoration: underline; font-weight: bold;">Shipping Information</span><br/>
                                Name: <%= name %> <br/>
                                Phone: <%= phone %> <br/>
                                Email: <%= email %><br/>
                                Address: <%= shippingAddress %> <br/>
                                City: <%= shippingCity %> <br/>
                                State: <%= shippingState %> <br/>
                                Zipcode: <%= shippingZip %> <br/>
                                <br/>
                                <span style="text-decoration: underline; font-weight: bold;">Billing Information</span><br/>
                                Cardholder Name: <%= cardName %> <br/>
                                Cardnumber: <% out.println(cardNumber.substring(0,4)); %>************ <br/>
                                Expiration Date: <%= expMonth %>/<%= expYear %> <br/>
                                Address: <%= billingAddress %> <br/>
                                City: <%= billingCity %> <br/>
                                State: <%= billingState %> <br/>
                                Zipcode: <%= billingZip %> <br/>
                                
                            </div>
                            <div style="float: left; width: 600px; margin-left: 20px; padding: 8px;">
                                <div style="text-align: center; font-size: 1.4em; font-weight: bold;">Your Order</div>
                                <hr/>
                                <div>
                                    
                                    <table class="shop">
                    <tr>
                        <th></th>
                        <th>Name</th>
                        <th>Price</th>
                        <th></th>
                    </tr>
                    <tr>
                        <% 
                       Cart cart = (Cart) session.getAttribute("cart"); 
                       session.setAttribute("cart", cart);
                       ArrayList<LineItem> items = cart.getItems();
                       for (int i=0; i<items.size(); i++)
                       {
                           Products product = items.get(i).getProduct();
                                
                        %>  


                        <td><img src='<% out.println(request.getContextPath() + product.getImage_link()); %>' width="150" height='125' /></td>
                        <td><%= product.getName() %></td>
                        <td>$<%= product.getPrice() %></td>                        
                    </tr>

<% } %>
                    

                </table>


                <div style="text-align: right; margin-right: 40px; margin-top: 10px;">
                    <span style="font-weight: bold; font-size: 1.3em;">SubTotal:</span> <span style="color: #002B6B;">$<%
                    int total = 0;
                       
                       for (int i=0; i<items.size(); i++)
                       {
                           
                           total += Double.valueOf(items.get(i).getProduct().getPrice());  
                    
                       }
                       
                       out.println(String.valueOf(total));
                    %></span></div>
                                    
                                    
                                </div>
                            </div>
                            <div style="clear: both;"></div>
                            
                        </div>

                        
                        <div style="text-align: center; margin-top: 10px;">
                            <input type="submit" value="Confirm Order" style="height: 30px;" />
                        </div>
                    </form>
                </div>
  
            </div>
            <div id="footer">
               &copy; 2013 | All Rights Reserved
           </div>
            
        </div>
        
        
        
    </body>
</html>
